<?php
require_once (dirname(__FILE__).'/include/common.inc.php');


# 页面级别
# 0 = 所有人都可以访问
$conf_web_page_level = 0; 

class myPage extends page{
	private $order= 0;
	private $id = 0;
	private $num = 0;
	function __construct(){
		parent::__construct();
		if(isset($_GET['order'])){
			$this->order = $_GET['order'];
		}
		if(isset($_GET['id'])){
			$this->id = $_GET['id'];
		}
		if(isset($_GET['num'])){
			$this->num = $_GET['num'];
		}
	}
	function getNumbers(){
		return $this->num;
	}
	function getPageOrder(){
		return $this->order;
	}
	
	function getOrder(){
		if($this->id == 0){
			return null;
		}
		$row; 
		try{
			$sql = "
				SELECT cs2_hsell.hsellId,cs2_hsell.prodId, cs2_prod.name, cs2_prod.model, cs2_hsell.title,
					cs2_prod.info,cs2_prod.barcode,cs2_prod.size_l,cs2_prod.size_w,
					cs2_prod.size_h,weight,cs2_prod.cateId,icon,iconinfo,num,contents,price,sprice,
				IFNULL((SELECT cs2_image.fileId FROM cs2_image 
					WHERE cs2_image.prodId=cs2_prod.prodId AND cs2_image.defId=0 LIMIT 0,1),'no_image') AS fileId 
				FROM cs2_hsell LEFT JOIN cs2_prod ON (cs2_prod.prodId = cs2_hsell.prodId)
				 WHERE (hsellId=".$this->id.")";
			
			$row = $this->database->get_one($sql);
		}catch (Exception $e) {
			$row = null;
		}
		return $row;
	}
	
	function ajax_callback(){
		parent::ajax_callback();
		return json_encode($this->ajax_json);
	}
}
$pg = new myPage();
# 载入页面
if($_SERVER['REQUEST_METHOD'] != 'POST'){
	$config->smarty->assign('getNumbers', $pg->getNumbers());
	$config->smarty->assign('getPageOrder', $pg->getPageOrder());
	$config->smarty->assign('getOrder', $pg->getOrder());
	# 加载页面
	$pg->render($config->temp_page_path);
}else{
	print_r($pg->ajax_callback());
}


?>